import os
import sys

import click

sys.path.append(os.path.join(os.path.dirname(__file__), "../.."))

from py_xcp_bridge.cli.crc_table_builder import build_crc_table


@click.group()
def cli():
    '''
    xcp slave command line interface
    '''
    pass


@cli.command()
@click.option("--poly", help="CRC 多项式参数[0xAAAA]", type=str, required=True)
@click.option("--reflect_in", help="是否反转输入[true|false]", type=bool, required=True)
@click.option("--reflect_out", help="是否反转输出[true|false]", type=bool, required=True)
def crc_table_builder(poly:str, reflect_in:bool, reflect_out:bool):
    # print("type of poly:", type(poly))
    # print("type of reflect_in:", type(reflect_in))
    # print("type of reflect_out:", type(reflect_out))
    build_crc_table(int(poly, 16), reflect_in, reflect_out)

  
if __name__ == '__main__':
    cli()